<template>
    <div class="mui-numbox" data-numbox-min='1'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input 
            id="test" class="mui-input-numbox" type="number" 
            v-model="this.$store.state.car[i].count"  
            ref="numbox" readonly 
            @change="numberChange"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
import mui from "../../lib/mui/js/mui.min.js";

export default {
    data () {
        return {
            count:[]
        }
    },
    mounted() {
        mui(".mui-numbox").numbox();
        // console.log(this.max)
    },
    props:['i','initcount','goodsid'],
    methods:{
        numberChange () {
            // 操作Dom refs.ref的值
            // console.log(this.$refs.numbox.value)
            // 调用vuex中方法重新存入本地数据
            this.$store.commit('updateGoodsInfo',{
                id:this.goodsid,
                count:this.$refs.numbox.value
            })
        }
    }
};
</script>

<style lang="scss" scoped>
.mui-numbox {
    height: 25px;;
}
</style>


